USE [BMIG_MENSUAL_POST_CADENA]

 -- creating the store procedure
IF EXISTS (SELECT name 
	   FROM   sysobjects 
	   WHERE  name = 'WASP_M0010_DROP_TABLA'
	   AND 	  type = 'P') 
	DROP PROCEDURE WASP_M0010_DROP_TABLA
GO

CREATE PROCEDURE [dbo].[WASP_M0010_DROP_TABLA] AS
begin    
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ingreso_produccion_codigos_seguros]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    BEGIN
      drop table [dbo].[ingreso_produccion_codigos_seguros]
    END
  
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ingreso_produccion_valores_seguros]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    BEGIN
      drop table [dbo].[ingreso_produccion_valores_seguros]
    END
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ingreso_produccion_seguros]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    BEGIN
      drop table [dbo].[ingreso_produccion_seguros]
    END
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ingreso_produccion_numero_telefono]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    BEGIN
      drop table [dbo].[ingreso_produccion_numero_telefono]
    END
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ing_produccion_temp]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    BEGIN
      drop table [dbo].[ing_produccion_temp]
    END
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ing_produccion]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    BEGIN
      drop table [dbo].[ing_produccion]
    END
  
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ingreso_produccion_seguro_vida]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    BEGIN
      drop table [dbo].[ingreso_produccion_seguro_vida]
    END
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ingreso_produccion_seguro_asisten]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    BEGIN
      drop table [dbo].[ingreso_produccion_seguro_asisten]
    END
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ingreso_produccion_seguro_degrav]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    BEGIN
      drop table [dbo].[ingreso_produccion_seguro_degrav]
    END
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ing_produccion_total]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    BEGIN
      drop table [dbo].[ing_produccion_total]
    END
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ingreso_produccion_UF]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    BEGIN
      drop table [dbo].[ingreso_produccion_UF]
    END
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Produccion_Cuotas]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    BEGIN
      drop table [dbo].[Produccion_Cuotas]
    END
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ing_produc_val_seg_aux]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    BEGIN
      drop table [dbo].[ing_produc_val_seg_aux]
    END
    
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ing_produc_cod_seg_aux]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    BEGIN
      drop table [dbo].[ing_produc_cod_seg_aux]
    END
END    
